package thread;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-09-26
 * Time: 8:44
 */
public class ThreadDemon32 {
    public static void main(String[] args) {
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("执行任务1，时间为1秒后");
            }
        }, 1000);

        timer.schedule(new TimerTask(){
            @Override
            public void run() {
                System.out.println("执行任务2，时间为2秒后");
            }
        },2000);


        timer.schedule(new TimerTask(){
            @Override
            public void run() {
                System.out.println("执行任务3，时间为3秒后");
            }
        },3000);
    }
}
